import { getPhoneCode } from "@/api/login";
import captcha from "./tencentCaptcha";
import { interpreter } from "@/api/request";

export default async function sendCode(phone: string) {
  const res: any = await captcha();
  if (res) {
    return await send(phone, res);
  }
  return false;
}

export async function send(phone: string, res: any) {
  const [err] = await interpreter(getPhoneCode(phone, res.ticket, res.randstr));
  if (!err) {
    return true;
  }
  return false;
}
